local skel = fk.CreateSkill {
  name = "lb__zhuhuo",
}

Fk:loadTranslationTable {
  ["lb__zhuhuo"] = "逐火",
  [":lb__zhuhuo"] = "当一名角色受到你造成的伤害时，你可以横置并从弃牌堆获得一张火【杀】，然后其也可以如此做。",

  ["#lb__zhuhuo"] = "逐火：你可以横置并从弃牌堆获得一张火【杀】",

  --["$lb__zhuhuo1"] = "",
  --["$lb__zhuhuo2"] = "",
}

skel:addEffect(fk.DamageInflicted, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and data.from and data.from == player and not player.chained
  end,
  on_cost = function(self, event, target, player, data)
    return --(data.card and data.card.skillName == "lb__fayan" and player.hp > 1) or  --强致发动
        (data and data.card and data.card.skillName == "lb__fayan" and player.hp > math.floor(player.maxHp / 2)) or --9.2
        player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#lb__zhuhuo" })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if (data and data.card and data.card.skillName == "lb__fayan" and player.hp > 1) then
      data.damageType = fk.FireDamage
    end
    player:setChainState(true)
    local id = room:getCardsFromPileByRule(".|.|.|.|fire__slash", 1, "discardPile")
    if #id > 0 then
      room:obtainCard(player, id, true, fk.ReasonJustMove)
    end
    if target and (not target.chained) and room:askToSkillInvoke(target, { skill_name = skel.name, prompt = "#lb__zhuhuo" }) then
      target:setChainState(true)
      id = room:getCardsFromPileByRule(".|.|.|.|fire__slash", 1, "discardPile")
      if #id > 0 then
        room:obtainCard(target, id, true, fk.ReasonJustMove)
      end
    end
  end,
})

skel:addEffect(fk.EventAcquireSkill, { -- 保险起见
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(skel.name, true, true) and data.skill:getSkeleton() and
    data.skill:getSkeleton().name == "lb__fenxiao_zhuhuo"
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:handleAddLoseSkills(player, "-lb__zhuhuo", nil, false, true)
  end,
})

return skel